package com.lemon.action;

import java.util.Map;

import com.lemon.domain.Employee;
import com.lemon.service.EmployeeService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private EmployeeService service = new EmployeeService();
	private String username;
	private String password;

	@Override
	public String execute() throws Exception {
		Employee employee = service.login(username, password);
		if (employee != null) {
			ActionContext context = ActionContext.getContext();
			Map<String, Object> session = context.getSession();
			session.put("employee", employee);
			return SUCCESS;
		}
		return NONE;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

}
